/**
Company: Sarkar software technologys
WebSite: http://www.sarkar.cn
Author: yeganaaa
Date : 5/18/18
Time: 4:55 PM
 */

package Cn.Sarkar.MMS

import Cn.Sarkar.Configuration.makeConfig
import com.google.gson.GsonBuilder
import io.ktor.application.Application
import io.ktor.server.cio.CIO
import io.ktor.server.engine.*
import io.ktor.server.netty.Netty
import java.io.File

data class ApplicationConfiguration(var host: String = "0.0.0.0", var port: Int = 8080)

internal fun createServer(module: Application.() -> Unit): ApplicationEngine {



    val config = makeConfig<ApplicationConfiguration>("Configuration${File.separator}Boot.json", ApplicationConfiguration::class){
        ApplicationConfiguration()
    }

    return embeddedServer(Netty, applicationEngineEnvironment {
        module(module)

        connector {
            host = config.host
            port = config.port
        }




//        connector {
//            host = "127.0.0.1"
//            port = 7777
//        }
    })
}